using System;
using System.Collections.Generic;
using System.Text;

using IGlobalist.Cms.Model.Common;

namespace IGlobalist.Cms.Model
{
    [Serializable]
    public class User : CmsObject, IUser
    {
        #region IUser Members
       
        public string[] Roles
        {
            get
            {
                
                string roles = (string) GetExtPropertyValue("Roles");
                if (string.IsNullOrEmpty(roles))
                    return null;
                return roles.Split(',');
            }
            set
            {
                string roles = ModelUtils.ConvertArray2String(value,',');
                SetExtPropertyValue("Roles", roles);
                
            }
        }

     
        public string Password
        {
            get
            {
                return (string)GetExtPropertyValue("Password");
            }
            set
            {
                SetExtPropertyValue("Password", value);
            }
        }

        public string UserName
        {
            get
            {
                return Name;
            }
            set
            {
                Name = value;
            }
        }

        
        public string Email
        {
            get
            {
                return (string)GetExtPropertyValue("Email");
            }
            set
            {
                SetExtPropertyValue("Email", value);

            }
        }

        public string Firstname
        {
            get
            {
                return (string)GetExtPropertyValue("Firstname");
            }
            set
            {
                SetExtPropertyValue("Firstname", value);

            }
        }

        public string Lastname
        {
            get
            {
                return (string)GetExtPropertyValue("Lastname");
            }
            set
            {
                SetExtPropertyValue("Lastname", value);

            }
        }

        public string Middle
        {
            get
            {
                return (string)GetExtPropertyValue("Middle");
            }
            set
            {
                SetExtPropertyValue("Middle", value);

            }
        }

        public string Address
        {
            get
            {
                return (string)GetExtPropertyValue("Address");
            }
            set
            {
                SetExtPropertyValue("Address", value);

            }
        }

        public string Phone
        {
            get
            {
                return (string)GetExtPropertyValue("Phone");
            }
            set
            {
                SetExtPropertyValue("Phone", value);

            }
        }

        public string Zipcode
        {
            get
            {
                return (string)GetExtPropertyValue("Zipcode");
            }
            set
            {
                SetExtPropertyValue("Zipcode", value);

            }
        }

        public string City
        {
            get
            {
                return (string)GetExtPropertyValue("City");
            }
            set
            {
                SetExtPropertyValue("City", value);

            }
        }

        public string Country
        {
            get
            {
                return (string)GetExtPropertyValue("Country");
            }
            set
            {
                SetExtPropertyValue("Country", value);

            }
        }


        //public UserType Type
        //{
        //    get
        //    {
        //        return (UserType)Enum.Parse(typeof(UserType), (string)this.GetExtPropertyValue("Type"));
        //    }
        //    set
        //    {
        //        this.SetExtPropertyValue("Type", value);
        //    }
        //}


        #endregion

        #region IXml Members

        public bool FromXml(string xml)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public string ToXmlString()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion

        #region ICmsObject Members


        public bool FromCmsObject(ICmsObject obj)
        {
            base.FromCmsObject(obj);
            

            return true;

        }

        #endregion


    }
}
